(function (vc) {
    vc.extends({
        data: {
            doAllocationOrderInfo: {
                orderId: '',
                stateName: '',
                state: '',
                staffId: '',
                staffName: '',
                createTime: '',
                remark: '',
                stateRemark: '',
                shopId: '',
                shopName: '',
                srcShId: '',
                srcShName: '',
                targetShId: '',
                targetShName: '',
                targetShopId: '',
                targetShopName: '',
                productCount: '',
                prodName: '',
                specName: '',
                specId: '',
                productId: '',
                actCount: '',
                inoutOrderProducts: []
            }
        },
        _initMethod: function () {
            let orderId = vc.getParam('orderId');
            if (!vc.notNull(orderId)) {
                vc.toast('非法操作');
                vc.getBack();
                return;
            }
            $that.doAllocationOrderInfo.orderId = vc.getParam('orderId');
            $that.doAllocationOrderInfo.staffName = vc.getParam("staffName");
            $that.doAllocationOrderInfo.stateName = vc.getParam('stateName');
            $that.doAllocationOrderInfo.createTime = vc.getParam("createTime");
            $that.doAllocationOrderInfo.stateRemark = vc.getParam('stateRemark');
            $that.doAllocationOrderInfo.shopName = vc.getParam('shopName');
            $that.doAllocationOrderInfo.srcShName = vc.getParam("srcShName");
            $that.doAllocationOrderInfo.targetShopName = vc.getParam("targetShopName");
            $that.doAllocationOrderInfo.targetShName = vc.getParam("targetShName");
            $that.doAllocationOrderInfo.shopId = vc.getParam("shopId");
            $that.doAllocationOrderInfo.specId = vc.getParam("specId");
            $that.doAllocationOrderInfo.productId = vc.getParam("productId");
            $that.doAllocationOrderInfo.productCount = vc.getParam("productCount");
            $that.doAllocationOrderInfo.actCount = vc.getParam("productCount");
            $that.doAllocationOrderInfo.state = vc.getParam("state");
            $that.doAllocationOrderInfo.targetShId = vc.getParam("targetShId");
            $that.doAllocationOrderInfo.srcShId = vc.getParam("srcShId");
            $that.doAllocationOrderInfo.targetShopId = vc.getParam("targetShopId");
            $that.doAllocationOrderInfo.staffId = vc.getParam("staffId");
            $that.doAllocationOrderInfo.prodName = vc.getParam("prodName");
            $that._listInoutOrderProduct();
        },
        _initEvent: function () {
        },
        methods: {
            _listInoutOrderProduct: function () {
                var param = {
                    params: {
                        page: 1,
                        row: 50,
                        specId: $that.doAllocationOrderInfo.specId,
                        productId: $that.doAllocationOrderInfo.productId,
                        shopId: $that.doAllocationOrderInfo.shopId
                    }
                };
                //发送get请求
                vc.http.apiGet('/product.queryProduct',
                    param,
                    function (json, res) {
                        var _storeOrderCartFeeManageInfo = JSON.parse(json);
                        $that.doAllocationOrderInfo.inoutOrderProducts = _storeOrderCartFeeManageInfo.data;
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            doInoutOrder: function () {
                $that.doAllocationOrderInfo.state = "4004";
                vc.http.apiPost(
                    '/allocationOrder/warehousingAllocationOrder',
                    JSON.stringify($that.doAllocationOrderInfo),
                    {
                        emulateJSON: true
                    },
                    function (json, res) {
                        let _json = JSON.parse(json);
                        if (_json.code == 0) {
                            vc.toast("入库成功");
                            vc.goBack();
                            return;
                        }
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                        vc.toast(errInfo);
                    });
            },
            _doCancelOrder: function () {
                $that.doAllocationOrderInfo.state = "3003";
                vc.http.apiPost(
                    '/allocationOrder/warehousingAllocationOrder',
                    JSON.stringify($that.doAllocationOrderInfo),
                    {
                        emulateJSON: true
                    },
                    function (json, res) {
                        let _json = JSON.parse(json);
                        if (_json.code == 0) {
                            vc.toast(_json.msg);
                            vc.goBack()
                            return;
                        }
                        vc.toast(_json.msg);
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                        vc.toast(errInfo);
                    });
            },
            _goBack: function () {
                vc.goBack();
            }
        }
    });
})(window.vc);
